from django.urls import path

from apps.meiduo_admin.login import admin_jwt_token_view
from apps.meiduo_admin.views.home import UserDailyActiveCountView, UserDailyOrderCountView, UserMonthCountView
from apps.meiduo_admin.views.image import SKUImageView, SKUListAPIView
from apps.meiduo_admin.views.permission import PermissionModelViewSet, ContentTypeListAPIView, GroupView, \
    GroupSimpleAPIView, AdminView, PermissionSimpleAPIView
from apps.meiduo_admin.views.sku import SKUModelViewSet, GoodsCategoryListAPIView, SPUListAPIView, \
    SPUSpecificationAPIView
from apps.meiduo_admin.views.user import UserListView

urlpatterns = [

    # path('authorizations/', obtain_jwt_token),
    path('authorizations/', admin_jwt_token_view),
    path('statistical/day_active/', UserDailyActiveCountView.as_view()),
    path('statistical/day_orders/', UserDailyOrderCountView.as_view()),
    path('statistical/month_increment/', UserMonthCountView.as_view()),
    path('users/', UserListView.as_view()),

    path('skus/simple/', SKUListAPIView.as_view()),
    # 三级分类
    path('skus/categories/', GoodsCategoryListAPIView.as_view()),
    # 所有SPU
    path('goods/simple/', SPUListAPIView.as_view()),
    path('goods/<spu_id>/specs/', SPUSpecificationAPIView.as_view()),
    # 权限类型获取
    path('permission/content_types/', ContentTypeListAPIView.as_view()),
    # 权限列表的获取 用于添加组
    path('permission/simple/', PermissionSimpleAPIView.as_view()),

    # 組列表的获取 用于添加管理員
    path('permission/groups/simple/', GroupSimpleAPIView.as_view()),
]

# 添加视图集的路由
from rest_framework import routers

router = routers.DefaultRouter()

# 图片管理
router.register('skus/images', SKUImageView, basename='images')

# sku管理
router.register('skus', SKUModelViewSet, basename='sku')

# 权限管理
router.register('permission/perms', PermissionModelViewSet, basename='perms')
# 组 路由
router.register('permission/groups', GroupView, basename='group')
# 　管理員　路由
router.register('permission/admins', AdminView, basename='admin')

# 把路由信息 合并过来
urlpatterns += router.urls

print(urlpatterns)
